﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using StuMngVan.Dals;
using StuMngVan.Entities;

namespace StuMngVan
{
    public partial class FormAddTeacher : Form
    {
        public FormAddTeacher()
        {
            InitializeComponent();
        }

        private void FormAddTeacher_Load(object sender, EventArgs e)
        {
            
            //cboCourse.Items.Add(1);
            //cboCourse.Items.Add(2);
            //cboCourse.Items.Add(3);
            //cboCourse.Items.Add(4);
            //cboCourse.Items.Add(5);
            //cboCourse.Items.Add(6);
            //cboCourse.Items.Add(7);
            //cboCourse.Items.Add(8);
            //cboCourse.Items.Add(9);
            //cboCourse.Items.Add(10);
            ///默认选择下拉框第1个值
            //cboCourse.SelectedIndex = 0;
            //【高月 2013-2-19-223453】
            //List<CourseInfo> list = new List<CourseInfo>();
            //foreach (CourseName course in Enum.GetValues(typeof(CourseName)))
            //{
            //    //if (course != CourseName.未知)
            //    //{
            //        CourseInfo tpCourse = new CourseInfo();
            //        tpCourse.CourseID = Convert.ToInt32(course);
            //        tpCourse.Description = course.ToString();

            //        list.Add(tpCourse);
            //    //}
            //}

            //cboCourse.DataSource = list;
            //cboCourse.DisplayMember = "Description";
            //cboCourse.ValueMember = "CourseID";
            ////cboCourse.SelectedIndex = 0;

            DataTable dtCourses = Dal4Teacher.GetCourses();
            cboCourse.DataSource = dtCourses;
            cboCourse.DisplayMember = "CourseName";
            cboCourse.ValueMember = "CourseID";
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            string sName = txtName.Text;
            int iTeachingExperience = Convert.ToInt16(txtTeachingExperience.Text);
            //int iCourseID = Convert.ToInt16(cboCourse.Text);
            int iCourseID = Convert.ToInt16(cboCourse.SelectedValue);
            string sRemark = txtRemark.Text;
            Dal4Teacher.InsertTeacher(sName, iTeachingExperience, iCourseID, sRemark);
            MessageBox.Show("恭喜你添加教师信息成功！");
            this.Close();
        }


    }
}
